<template>
    <div>
        <Tabs :value="currmun" @on-click="clicktab">
            <TabPane :label="`患者（${totallist.patientCount || 0}）`" name="patient">
                <patientTable ref="patientTable" @alltotal="alltotal"></patientTable>
            </TabPane>
            <TabPane :label="`线索（${totallist.clueCount || 0}）`" name="clues">
                <cluesTable ref="cluesTable" @alltotal="alltotal"></cluesTable>
            </TabPane>
            <TabPane :label="`通话（${totallist.callCount || 0}）`" name="call">
                <callTable ref="callTable" @alltotal="alltotal"></callTable>
            </TabPane>
            <TabPane :label="`微信（${totallist.wechatCount || 0}）`" name="wechat">
                <wechatTable  ref="wechatTable" @alltotal="alltotal"></wechatTable>
            </TabPane>
        </Tabs>
    </div>
</template>
<script>
import { mapState, mapMutations} from 'vuex';
import patientTable from './patientTable';
import cluesTable from './cluesTable';
import callTable from'./callTable';
import wechatTable from'./wechatTable';
import{searchCount}from '@/api/globalsearch.js';
export default {
    components: {patientTable,cluesTable,callTable,wechatTable},
    computed: {
    ...mapState('admin/account', [
        'inputSearch',
    ]),
    ...mapMutations('admin/patient', ['setinputSearch']),
    },
    data(){
        return{
            currmun: 'patient',
            totallist: {},
            search: ''
        };
    },
    methods: {
        initial(val){
            console.log(val,'val');
            this.search = val;
            this.searchAll(val);
            this.$refs.patientTable.initial(val);
            // this.$refs.cluesTable.initial(val);
            // this.$refs.callTable.initial(val);
            // this.$refs.wechatTable.initial(val);
        },
        // 获取总数
        searchAll(val){
            searchCount({true_keyword: val}).then(res => {
                this.totallist = res;
            });
        },
        clicktab(e) {
            switch(e) {
                case 'patient':
                    this.$refs.patientTable.initial(this.search);
                    break;
                case 'clues':
                    this.$refs.cluesTable.initial(this.search);
                    break;
                case 'call':
                    this.$refs.callTable.initial(this.search);
                    break;
                case 'wechat':
                    this.$refs.wechatTable.initial(this.search);
                    break;
            }
        },
        alltotal(e) {
            //
        }
    }
};
</script>